package 力扣日常刷题.木22一月.第15天0127;

import java.util.HashSet;

/**
 * @author 帅小伙
 * @date 2022/1/27
 * @description
 */
public class Demo07简单字符串统计一致字符串的数目 {


    public int countConsistentStrings(String allowed, String[] words) {
        int ans = 0;
        HashSet<Character> set = new HashSet<>();

        for (char c : allowed.toCharArray()) {
            set.add(c);
        }
        for (String word : words) {
            for (int i = 0; i < word.length(); i++) {
                if(!set.contains(word.charAt(i)))break;
                if(i == word.length() - 1) ans++;
            }
        }
        return ans;
    }

}
